package com.kfm.servlet;

import com.kfm.model.SEmp;
import com.kfm.service.SEmpService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/all")
public class ListServlet extends HttpServlet {

    private SEmpService service = new SEmpService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<SEmp> all = service.findAll();
        // 存储内容
        req.setAttribute("all", all);
        req.getRequestDispatcher("/WEB-INF/all.jsp").forward(req, resp);

    }
}
